﻿<!doctype html>
<html>
<head>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
<title>会员卡</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/header&footer.js"></script>
<script src="js/utils.js" type="text/javascript" ></script>
<script src="js/check.js" type="text/javascript" ></script>
<script type="text/javascript" src="js/openId1.js"></script>
<script type="text/javascript" src="js/qmsk-1.2.js"></script>
<script type="text/javascript" src="js/zepto.js"></script>

<script type="text/javascript">
/**
 * 页面加载完就加载数据
 */
$(function(){
	addCardCss("","")
	// 从url 中解析 shopId 和 openId	
	/* 这里先请求信息成功后在回调函数中请求二维码图片，原因是在请求信息的时候会判断是否是会员，如果不是，剩下的操作也就不做了 */
	getMemberCardInfo();
});

/**
 * 根据shopId 和 openId 加载会员卡的数据
 */
function getMemberCardInfo(){
	$.get('../member/find/memberCardInfo/'+_shopId+'/'+_openId ,function(message){
		if(message.state==0){
			
			var customerName=getHeadIndexValue(0,message,'customerName');
			var integralAmount=getHeadIndexValue(0,message,'integralAmount');
			var depositAmount=getHeadIndexValue(0,message,'depositAmount');
			var memberCardNo=getHeadIndexValue(0,message,'memberCardNo');
			var levelName=getHeadIndexValue(0,message,'levelName');
			var coupondAmount=getHeadIndexValue(0,message,'coupondAmount');
			var cashcoupondAmount= getHeadIndexValue(0,message,'cashCouponAmount');
			
			$("#levelName").html(levelName);
			$("#customerName").html(customerName);
			$("#integralAmount").html(integralAmount);
			$("#depositAmount").html(depositAmount);
			$("#memberCardNo").html('No.'+memberCardNo);
			$("#coupondAmount").html(coupondAmount);
			$("#cashcoupondAmount").html(cashcoupondAmount);
			
			//加载 二维码图片
			getMemberQrCode();
			getCar(openId)
			
			addCardCss(levelName)

		}
		else{
				$(".noMember").show()
			//TODO 这里有可能会提示不是会员，如果不是会员要做的操作添加到这里
		}
	},'json');
}

/**
 * 获取二维码图片
 */
function getMemberQrCode(){
	$.get("../Qr/insertQR/"+_openId+"/"+_shopId, function(message) {
		if(message.state==0)
		{
	   		var qrUrl=getHeadIndexValue(0,message,'qrUrl');
            if(qrUrl == null){
            	 alert("二维码生成失败");
            }
            else{
	         	$("#qrcodepic").attr('src',qrUrl);
            }
		}
		else{
			alert(message.msg);
		}
	},'json');
}

function goYH(){
	window.location.href="../html/together.html?openId="+_openId+"&shopId="+_shopId
}
function goXF(){
	window.location.href="../html/searchMem.html?openId="+_openId+"&shopId="+_shopId
}
function goCar(){
	window.location.href="../html/html/mine/myCar.html?openId="+_openId+"&shopId="+_shopId
}
function goBD(){
	window.location.href="../html/register/register.html?openId="+_openId+"&shopId="+_shopId
}
function goHY(){
	window.location.href="http://211.149.154.92/lldweb/html/shopIndex/280000022/memberIndex/member.html";
}

/* function getCar(openId){
	var dt = _findInfo("../customerCarInfo/find/customerCarInfo/"+openId, null)
	if(IsNotEmpty(dt)&&dt.state==0){
		for(var i=0;i<dt.result.data.length;i++){
			var htm="<p class=\"message\"><span style=\"width:50%;\">车牌号："+getHtmlString(getHeadIndexValue(i, dt, "license"))+"</span>下次保养日期："+getHtmlString(getHeadIndexValue(i, dt, "nextDate")).substring(0,10)+"</p>	<p class=\"message\"><span style=\"width:50%;\">保险到期："+getHtmlString(getHeadIndexValue(i, dt, "insEndDate")).substring(0,10)+"</span>车辆年检："+getHtmlString(getHeadIndexValue(i, dt, "checkDate")).substring(0,10)+"</p>"
			if(i!=0){
				var htm="<br><p class=\"message\"><span style=\"width:50%;\">车牌号："+getHtmlString(getHeadIndexValue(i, dt, "license"))+"</span>下次保养日期："+getHtmlString(getHeadIndexValue(i, dt, "nextDate")).substring(0,10)+"</p>	<p class=\"message\"><span style=\"width:50%;\">保险到期："+getHtmlString(getHeadIndexValue(i, dt, "insEndDate")).substring(0,10)+"</span>车辆年检："+getHtmlString(getHeadIndexValue(i, dt, "checkDate")).substring(0,10)+"</p>"
			}
			$("#carInfo").append(htm)
		}
	}
} */
function addCard(levelName){
	if(levelName==="微信会员"){
		addCardCss("pk",levelName)
	}else if(levelName==="银卡"){
		addCardCss("yk",levelName)

	}else if(levelName==="金卡"){
		addCardCss("jk",levelName)
	}else if(levelName==="钻石卡"){
		addCardCss("zsk",levelName)
	}
}
function addCardCss(type,typeName){
	$("#cardType").html(typeName)
	$(".Card ").css("background","rgba(0, 0, 0, 0) url('images/card_"+type+".jpg') no-repeat scroll 0 0")
}
</script>
<style type="text/css">
p.message{ font-size:12px;text-align:left;font-weight:bold;line-height:22px;border-bottom:1px dashed #ccc;}
p.message span{display:inline-block;}
</style>
</head>

<body style="background-color:hsl(0,0%,90%);">
	<div class="wrapper">
          <div class='placeTit' id="cardType"></div>
		<div class="container">
			<div class="Card">
				<div class="cardHead">
					<span id="levelName"></span><strong><img src="images/HSlogo.png"></strong>
				</div>
				<dl class="memberDet">
					<dt><img id="qrcodepic"/>
					</dt>
					<dd>
						<p>
							<span>姓名：</span><span id="customerName"></span>
						</p>
						<p>
							<span>积分：</span><span id="integralAmount"></span>
						</p>
						<p>
							<span>储值：</span><span id="depositAmount"></span>
						</p>
						<p>
							<span>代金券：</span><span id="cashcoupondAmount"></span>&nbsp;<span>优惠券：</span><span id="coupondAmount" style="margin-right:5px;">0000</span>
						</p>
					</dd>
				</dl>
				<div class="cardFoot" id="memberCardNo"></div>
      <div  class="clickJoin noMember" style="display: none;">您还没有绑定档案，请点击绑定！</div>
			</div>
    <div class="getTips red noMember" style="display: none;text-align:center;margin-bottom:5px;">您还不是会员哦！</div>
    <section class="module">
      <ul>
        <li onclick="goHY()">会员手册<span class="go"></span></li>
      </ul>
    </section>
    <section class="module">
      <ul>
        <li onclick="goBD()" class="noMember" style="display: none;" >绑定会员卡<span class="go"></span></li>
        <li onclick="goYH()" >聚优惠<span class="go"></span></li>
        <li onclick="goXF()">消费查询<span class="go"></span></li>
        <li onclick="goCar()">我的车辆<span class="go"></span></li>
      </ul>
    </section>
			<div id="carInfo">
           <!--  <p class="message"><span style="width:50%;">车牌号：京A86547</span>下次保养日期：2014-2-20</p>	
            <p class="message"><span style="width:50%;">保险到期：2014-5-7</span>车辆年检：2014-5-7</p>
            --> </div>
           <!-- <p class="txt brown">1、本卡仅限本人使用，转让、转借本卡可能导致您的会员权益受损；</p>
			<p class="txt brown">2、消费时请主动出示本卡，以获得您应有的专属权益（包括积分、优
      惠、折扣等等）</p>
			<p class="txt brown">3、请妥善保管本卡以及相关密码，随意让他人拍摄、泄露密码等行为
      可能会损害您的账户安全；</p>
			<p class="txt brown">4、发行公司享受此卡在法律许可范围内的最终解释权。</p>-->
		</div>
	</div>
</body>
</html>
